package top.codedance.iotp.converter.bean;

public class MasterConnectParam extends ComConnectParam implements ConnectParam {
    private String type;
    private int com;
    private int id;

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getCom() {
        return com;
    }

    public void setCom(int com) {
        this.com = com;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setComConnectParam(ComConnectParam ccp){
        this.setComName(ccp.getComName());
        this.setBaudRate(ccp.getBaudRate());
        this.setDataBits(ccp.getDataBits());
        this.setStopBits(ccp.getStopBits());
        this.setParity(ccp.getParity());
    }

    @Override
    public boolean isComType() {
        return type.toLowerCase().equals("serial") || type.toLowerCase().equals("rtu") || type.toLowerCase().equals("ascii");
    }

    @Override
    public boolean isNetType() {
        return type.toLowerCase().equals("tcp") || type.toLowerCase().equals("udp");
    }

    @Override
    public boolean isModbus() {
        return type.toLowerCase().equals("tcp") || type.toLowerCase().equals("udp") || type.toLowerCase().equals("rtu") || type.toLowerCase().equals("ascii");
    }
}
